Skip to content

Commit

Permalink
add classes for dialog, focus element and sourcemap files (#14)
Browse files Browse the repository at this point in the history
* add the *-dialog-class and *-focus options for the actions with dialogs
* set a new version
* remove unnecesary dist files
* add the source map files
* update the dist files
  • Loading branch information
dealfonso authored Nov 7, 2024
1 parent 92f1643 commit c579b54
Show file tree
Hide file tree
Showing 17 changed files with 259 additions and 3,006 deletions.
40 changes: 24 additions & 16 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -26,21 +26,22 @@ LIBRARY_NAME := $(if $(LIBRARY_NAME),$(LIBRARY_NAME),$(current_dir))
# Folder in which the build files will be located
DIST_FOLDER := $(if $(DIST_FOLDER),$(DIST_FOLDER),dist)
# The name of the build files
FILENAME = $(DIST_FOLDER)/$(LIBRARY_NAME)
FILEPATH = $(DIST_FOLDER)/$(LIBRARY_NAME)
FILENAME := $(notdir $(FILEPATH))

# Files of the dependencies to include in the build
DEP_FILES = $(foreach fd, $(DEPENDS), $(DEPENDS_FOLDER)/$(fd)/dist/$(fd).module.js)

# The version of this library (this is intended to track the version of this template)
MAKEFILE_VERSION = 1.1.0

RESULT_FILES = $(FILENAME).full.js $(FILENAME).min.js $(FILENAME).js $(FILENAME).compress.js $(FILENAME).module.js
RESULT_FILES = $(FILEPATH).full.js $(FILEPATH).min.js $(FILEPATH).js $(FILEPATH).compress.js $(FILEPATH).module.js

INPUT_FILES = $(FILENAME).raw.js $(DEP_FILES)
INPUT_FILES = $(FILEPATH).raw.js $(DEP_FILES)

all: $(RESULT_FILES)

module: $(FILENAME).module.js
module: $(FILEPATH).module.js

clean:
rm -f $(RESULT_FILES)
Expand All @@ -51,37 +52,44 @@ cleanall: clean

depends: $(DEP_FILES)

$(FILENAME).full.js: $(FILENAME).raw.js $(DEP_FILES)
$(FILEPATH).full.js: $(FILEPATH).raw.js
@mkdir -p $(DIST_FOLDER)
cat $(DEP_FILES) $(FILENAME).raw.js | uglifyjs -e exports:window | js-beautify -t -s 1 -m 1 -j -n | cat notice - > $(FILENAME).full.js
cat $(FILEPATH).raw.js | uglifyjs -e exports:window | js-beautify -t -s 1 -m 1 -j -n | cat notice - > $(FILEPATH).full.js

$(FILENAME).js: $(FILENAME).raw.js $(DEP_FILES)
$(FILEPATH).js: $(FILEPATH).raw.js
@mkdir -p $(DIST_FOLDER)
cat $(DEP_FILES) $(FILENAME).raw.js | uglifyjs -e exports:window -b | js-beautify -t -s 1 -m 1 -j -n | cat notice - > $(FILENAME).js
cat $(FILEPATH).raw.js | uglifyjs -e exports:window -b | js-beautify -t -s 1 -m 1 -j -n | cat notice - > $(FILEPATH).js

$(FILENAME).min.js: $(FILENAME).raw.js $(DEP_FILES)
$(FILEPATH).min.js: $(FILEPATH).js
@mkdir -p $(DIST_FOLDER)
cat $(DEP_FILES) $(FILENAME).raw.js | uglifyjs -e exports:window --toplevel --module -m | cat notice.min - > $(FILENAME).min.js
cd $(DIST_FOLDER) && uglifyjs $(FILENAME).js --toplevel --module -m --source-map "filename='$(FILENAME).min.js.map',includeSources=true" -o $(FILENAME).min.js

$(FILENAME).compress.js: $(FILENAME).raw.js $(DEP_FILES)
$(FILEPATH).compress.js: $(FILEPATH).js
@mkdir -p $(DIST_FOLDER)
cat $(DEP_FILES) $(FILENAME).raw.js | uglifyjs -e exports:window --compress passes=3,dead_code=true,toplevel=true --toplevel --module -m -- | cat notice.min - > $(FILENAME).compress.js
cd $(DIST_FOLDER) && uglifyjs $(FILENAME).js --compress passes=3,dead_code=true,toplevel=true --toplevel --module -m --source-map "filename='$(FILENAME).compress.js.map',includeSources=true" -o $(FILENAME).compress.js

$(FILENAME).module.js: $(FILENAME).raw.js $(DEP_FILES)
$(FILEPATH).module.js: $(FILEPATH).raw.js
@mkdir -p $(DIST_FOLDER)
( cat notice; echo 'if (typeof imports === "undefined") { var imports = {}; }' ; cat $(DEP_FILES) $(FILENAME).raw.js | uglifyjs -e exports:imports | js-beautify -t -s 1 -m 1 -j -n ) > $(FILENAME).module.js
( cat notice; echo 'if (typeof imports === "undefined") { var imports = {}; }' ; cat $(FILEPATH).raw.js | uglifyjs -e exports:imports | js-beautify -t -s 1 -m 1 -j -n ) > $(FILEPATH).module.js

%.module.js:
$(MAKE) -C $(dir $(@D)) module

%.raw.js: $(FILES) $(PRE) $(POST)
%.raw.js: $(FILES) $(PRE) $(POST) $(DEP_FILES)
@mkdir -p $(DIST_FOLDER)
cat $(PRE) $(FILES) $(POST) > $(FILENAME).raw.js
cat $(DEP_FILES) $(PRE) $(FILES) $(POST) > $(FILEPATH).raw.js

################################################################################
# CHANGELOG
################################################################################
#
# 1.2.0
# * Add different variables for FILENAME and FILEPATH to avoid problems with the path
# * Change the creation of the raw file to use the dependencies as a prerequisite and create a true raw file
# * Add the creation of map source files for the minified and compressed versions
#
# ----------------------------------------------------------------
#
# 1.1.0
# * Reorder the parameters of the Makefile.
# * Add targets to build the files by their name so that "make" checks if the
Expand Down
48 changes: 40 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,11 @@ The default values for the options are the next:
data-confirm-button-confirm="Confirm"
data-confirm-button-cancel="Cancel"
data-confirm-button-close="true"
data-confirm-escape-key="true">clickme</button>
data-confirm-escape-key="true"
data-confirm-on-confirm=""
data-confirm-dialog-class=""
data-confirm-focus=""
>clickme</button>
```

### Verify Button
Expand Down Expand Up @@ -137,7 +141,9 @@ The default values for the options of the _verify_ button are the next:
data-verify-button-close="false"
data-verify-escape-key="true"
data-verify-header="true"
data-verify-footer="true">test verify</button>
data-verify-footer="true"
data-verify-dialog-class=""
data-verify-focus="">test verify</button>
```

### ShowMessage Button
Expand All @@ -163,7 +169,9 @@ The default values for the options of the _showmessage_ button are the next:
data-showmessage-button-close="true"
data-showmessage-escape-key="true"
data-showmessage-header="true"
data-showmessage-footer="true">test showmessage</button>
data-showmessage-footer="true"
data-showmessage-dialog-class=""
data-showmessage-focus="">test showmessage</button>
```

### Override Actions
Expand Down Expand Up @@ -257,7 +265,9 @@ The default values for the options of the _asynctask_ button are the next:
data-asynctask-button-cancel="Cancel"
data-asynctask-cancel=""
data-asynctask-header="true"
data-asynctask-footer="true">async task</button>
data-asynctask-footer="true"
data-asynctask-dialog-class=""
data-asynctask-focus="">async task</button>
```

#### A note on the tasks to execute
Expand Down Expand Up @@ -401,7 +411,11 @@ escapeKey: true,
// If falshi (i.e. null, 0, false, "false"), the head of the dialog will be hidden
header: true,
// If falshi (i.e. null, 0, false, "false"), the footer of the dialog will be hidden
footer: true
footer: true,
// The class to apply to the dialog
dialogClass: "",
// The selector to focus when the dialog is shown
focus: ""
```

The equivalent for html5 attributes are the snake-case version of each of them, with the prefix `data-verify-`; e.g. `data-verify-button-accept`, `data-verify-title-not-verified`, etc.
Expand All @@ -419,10 +433,16 @@ title: "The action requires confirmation",
buttonConfirm: "Confirm",
// The content for the button that cancels the action (it can be either plain text or a HTML fragment)
buttonCancel: "Cancel",
// The function to call when the action is confirmed. If it is a string, it will be evaluated as javascript, using _eval_
onConfirm: null,
// If falshi (i.e. null, 0, false, "false"), the button to close the dialog will not be shown
buttonClose: true,
// If falshi (i.e. null, 0, false, "false"), the esc key will not close the dialog (it will close it if true)
escapeKey: true
escapeKey: true,
// The class to apply to the dialog
dialogClass: "",
// The selector to focus when the dialog is shown
focus: ""
```

The equivalent for html5 attributes are the snake-case version of each of them, with the prefix `data-confirm-`; e.g. `data-confirm-button-confirm`, `data-confirm-title`, etc.
Expand All @@ -445,7 +465,11 @@ buttonClose: true,
// If falshi (i.e. null, 0, false, "false"), the head of the dialog will be hidden
header: true,
// If falshi (i.e. null, 0, false, "false"), the footer of the dialog will be hidden
footer: true
footer: true,
// The class to apply to the dialog
dialogClass: "",
// The selector to focus when the dialog is shown
focus: ""
```

The equivalent for html5 attributes are the snake-case version of each of them, with the prefix `data-showmessage-`; e.g. `data-showmessage-button-accept`, `data-showmessage-title`, etc.
Expand All @@ -467,6 +491,10 @@ title: null,
buttonAccept: "Accept",
// If falshi (i.e. null, 0, false, "false"), the esc key will not close the dialog (it will close it if true)
escapeKey: true,
// The class to apply to the dialog
dialogClass: "",
// The selector to focus when the dialog is shown
focus: ""
```

The equivalent for html5 attributes are the snake-case version of each of them, with the prefix `data-override-`; e.g. `data-override-button-accept`, `data-override-title`, etc.
Expand Down Expand Up @@ -523,7 +551,11 @@ cancel: null,
// If falshi (i.e. null, 0, false, "false"), the head of the dialog will be hidden
header: true,
// If falshi (i.e. null, 0, false, "false"), the footer of the dialog will be hidden
footer: true
footer: true,
// The class to apply to the dialog
dialogClass: "",
// The selector to focus when the dialog is shown
focus: ""
```

The `task` and `cancel` parameters may be either functions, promises or strings containing javascript code. If they are functions, they will be executed. If they are promises, they will be awaited for their finalization. If they are strings, they will be evaluated as javascript code.
Expand Down
3 changes: 1 addition & 2 deletions dist/powerbuttons.compress.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions dist/powerbuttons.compress.js.map

Large diffs are not rendered by default.

Loading

0 comments on commit c579b54

Please sign in to comment.