PluginProbe
ERP: Complete HR, Accounting & CRM Suite Built for WooCommerce / 1.2.6
ERP: Complete HR, Accounting & CRM Suite Built for WooCommerce v1.2.6
1.17.9 1.17.8 1.17.7 1.17.6 1.17.5 1.17.4 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.2.7 1.2.8 1.3.0 1.3.1 1.3.11 1.3.12 1.3.13 1.3.14 1.3.2 1.3.3 1.3.4 1.3.5 1.3.6 1.3.7 All 143 releases
erp / includes / class-scripts.php

class-scripts.php in ERP: Complete HR, Accounting & CRM Suite Built for WooCommerce 1.2.6, at includes/class-scripts.php

199 lines 9.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace WeDevs\ERP;
3
4 use WeDevs\ERP\Framework\Traits\Hooker;
5
6 /**
7 * Scripts and styles
8 */
9 class Scripts {
10
11 use Hooker;
12
13 /**
14 * Script and style suffix
15 *
16 * @var string
17 */
18 protected $suffix;
19
20 /**
21 * Script version number
22 *
23 * @var integer
24 */
25 protected $version;
26
27 /**
28 * Initialize the class
29 */
30 public function __construct() {
31 $this->suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
32 $this->version = '20150314';
33
34 $this->action( 'admin_enqueue_scripts', 'scripts_handler' );
35 }
36
37 /**
38 * Register and enqueue scripts and styles
39 *
40 * @return void
41 */
42 public function scripts_handler() {
43 $this->register_scripts();
44 $this->register_styles();
45
46 $this->enqueue_scripts();
47 $this->enqueue_styles();
48 }
49
50 public function register_scripts() {
51
52 // wp_register_script( $handle, $src, $deps, $ver, $in_footer );
53 $vendor = WPERP_ASSETS . '/vendor';
54 $js = WPERP_ASSETS . '/js';
55
56 // register vendors first
57 wp_register_script( 'erp-select2', $vendor . '/select2/select2.full.min.js', array( 'jquery' ), $this->version, true );
58 wp_register_script( 'erp-tiptip', $vendor . '/tiptip/jquery.tipTip.min.js', array( 'jquery' ), $this->version, true );
59 wp_register_script( 'erp-momentjs', $vendor . '/moment/moment.min.js', false, $this->version, true );
60 wp_register_script( 'erp-fullcalendar', $vendor . '/fullcalendar/fullcalendar' . $this->suffix . '.js', array( 'jquery', 'erp-momentjs' ), $this->version, true );
61 wp_register_script( 'erp-timepicker', $vendor . '/timepicker/jquery.timepicker.min.js', array( 'jquery', 'erp-momentjs' ), $this->version, true );
62 wp_register_script( 'erp-vuejs', $vendor . '/vue/vue' . $this->suffix . '.js', array( 'jquery' ), $this->version, true );
63 wp_register_script( 'erp-trix-editor', $vendor . '/trix/trix.js', array( 'jquery' ), $this->version, true );
64 wp_register_script( 'erp-nprogress', $vendor . '/nprogress/nprogress.js', array( 'jquery' ), $this->version, true );
65 wp_register_script( 'erp-jvectormap', $vendor . '/jvectormap/jvectormap.min.js', array( 'jquery' ), $this->version, true );
66 wp_register_script( 'erp-jvectormap-world-mill', $vendor . '/jvectormap/jvectormap-world-mill.js', array( 'jquery' ), $this->version, true );
67
68 // sweet alert
69 wp_register_script( 'erp-sweetalert', $vendor . '/sweetalert/sweetalert.min.js', array( 'jquery' ), $this->version, true );
70
71 // flot chart
72 wp_register_script( 'erp-flotchart', $vendor . '/flot/jquery.flot.min.js', array( 'jquery' ), $this->version, true );
73 wp_register_script( 'erp-flotchart-time', $vendor . '/flot/jquery.flot.time.min.js', array( 'jquery' ), $this->version, true );
74 wp_register_script( 'erp-flotchart-orerbars', $vendor . '/flot/jquery.flot.orderBars.js', array( 'jquery' ), $this->version, true );
75 wp_register_script( 'erp-flotchart-pie', $vendor . '/flot/jquery.flot.pie.min.js', array( 'jquery' ), $this->version, true );
76 wp_register_script( 'erp-flotchart-axislables', $vendor . '/flot/jquery.flot.axislabels.js', array( 'jquery' ), $this->version, true );
77 wp_register_script( 'erp-flotchart-categories', $vendor . '/flot/jquery.flot.categories.js', array( 'jquery' ), $this->version, true );
78 wp_register_script( 'erp-flotchart-tooltip', $vendor . '/flot/jquery.flot.tooltip.min.js', array( 'jquery' ), $this->version, true );
79 wp_register_script( 'erp-flotchart-resize', $vendor . '/flot/jquery.flot.resize.min.js', array( 'jquery' ), $this->version, true );
80 wp_register_script( 'erp-flotchart-valuelabel', $vendor . '/flot/jquery.flot.valuelabels.js', array( 'jquery' ), $this->version, true );
81 wp_register_script( 'erp-flotchart-navigate', $vendor . '/flot/jquery.flot.navigate.js', array( 'jquery' ), $this->version, true );
82 wp_register_script( 'erp-flotchart-selection', $vendor . '/flot/jquery.flot.selection.js', array( 'jquery' ), $this->version, true );
83 wp_register_script( 'erp-flotchart-stack', $vendor . '/flot/jquery.flot.stack.js', array( 'jquery' ), $this->version, true );
84
85 // core js files
86 wp_register_script( 'erp-popup', $js . '/jquery-popup' . $this->suffix . '.js', array( 'jquery' ), $this->version, true );
87 wp_register_script( 'erp-script', $js . '/erp' . $this->suffix . '.js', array( 'jquery', 'backbone', 'underscore', 'wp-util', 'jquery-ui-datepicker' ), $this->version, true );
88 wp_register_script( 'erp-file-upload', $js . '/upload' . $this->suffix . '.js', array( 'jquery', 'plupload-handlers' ), $this->version, true );
89 wp_register_script( 'erp-admin-settings', $js . '/settings' . $this->suffix . '.js', array( 'jquery' ), $this->version, true );
90
91 // tether.js
92 wp_register_script( 'erp-tether-main', $vendor . '/tether/tether.min.js', array( 'jquery' ), $this->version, true );
93 wp_register_script( 'erp-tether-drop', $vendor . '/tether/drop.min.js', array( 'jquery' ), $this->version, true );
94
95 // clipboard.js
96 wp_register_script( 'erp-clipboard', $vendor . '/clipboard/clipboard.min.js', array( 'jquery' ), $this->version, true );
97
98 // toastr.js
99 wp_register_script( 'erp-toastr', $vendor . '/toastr/toastr.min.js', array(), $this->version, true );
100 }
101
102 /**
103 * Register all the styles
104 *
105 * @return void
106 */
107 public function register_styles() {
108 $vendor = WPERP_ASSETS . '/vendor';
109 $css = WPERP_ASSETS . '/css';
110
111 wp_register_style( 'erp-fontawesome', $vendor . '/fontawesome/font-awesome.min.css', false, $this->version );
112 wp_register_style( 'erp-select2', $vendor . '/select2/select2.min.css', false, $this->version );
113 wp_register_style( 'erp-tiptip', $vendor . '/tiptip/tipTip.css', false, $this->version );
114 wp_register_style( 'erp-fullcalendar', $vendor . '/fullcalendar/fullcalendar' . $this->suffix . '.css', false, $this->version );
115 wp_register_style( 'erp-timepicker', $vendor . '/timepicker/jquery.timepicker.css', false, $this->version );
116 wp_register_style( 'erp-trix-editor', $vendor . '/trix/trix.css', false, $this->version );
117 wp_register_style( 'erp-flotchart-valuelabel-css', $vendor . '/flot/plot.css', false, $this->version );
118 wp_register_style( 'erp-nprogress', $vendor . '/nprogress/nprogress.css', false, $this->version );
119 wp_register_style( 'erp-jvectormap', $vendor . '/jvectormap/jvectormap.css', false, $this->version );
120
121 // jquery UI
122 wp_register_style( 'jquery-ui', $vendor . '/jquery-ui/jquery-ui-1.9.1.custom.css' );
123
124 // sweet alert
125 wp_register_style( 'erp-sweetalert', $vendor . '/sweetalert/sweetalert.css', false, $this->version );
126
127 // tether drop theme
128 wp_register_style( 'erp-tether-drop-theme', $vendor . '/tether/drop-theme.min.css', false, $this->version );
129
130 // toastr.js
131 wp_register_style( 'erp-toastr', $vendor . '/toastr/toastr.min.css', false, $this->version );
132
133 // core css files
134 wp_register_style( 'erp-styles', $css . '/admin.css', false, $this->version );
135
136 }
137
138 /**
139 * Enqueue the scripts
140 *
141 * @return void
142 */
143 public function enqueue_scripts() {
144 $screen = get_current_screen();
145 $screen_base = isset( $screen->base ) ? $screen->base : false;
146 $hook = str_replace( sanitize_title( __( 'HR Management', 'erp' ) ) , 'hr-management', $screen_base );
147
148 wp_enqueue_script( 'erp-select2' );
149 wp_enqueue_script( 'erp-popup' );
150 wp_enqueue_script( 'erp-script' );
151
152 wp_localize_script( 'erp-script', 'wpErp', array(
153 'nonce' => wp_create_nonce( 'erp-nonce' ),
154 'set_logo' => __( 'Set company logo', 'erp' ),
155 'upload_logo' => __( 'Upload company logo', 'erp' ),
156 'remove_logo' => __( 'Remove company logo', 'erp' ),
157 'update_location' => __( 'Update Location', 'erp' ),
158 'create' => __( 'Create', 'erp' ),
159 'update' => __( 'Update', 'erp' ),
160 'confirmMsg' => __( 'Are you sure?', 'wpuf' ),
161 'ajaxurl' => admin_url( 'admin-ajax.php' ),
162 'plupload' => array(
163 'url' => admin_url( 'admin-ajax.php' ) . '?nonce=' . wp_create_nonce( 'erp_featured_img' ),
164 'flash_swf_url' => includes_url( 'js/plupload/plupload.flash.swf' ),
165 'filters' => array(array('title' => __( 'Allowed Files' ), 'extensions' => '*')),
166 'multipart' => true,
167 'urlstream_upload' => true,
168 )
169 ) );
170
171 // load country/state JSON on new company page
172 if ( 'toplevel_page_erp-company' == $hook || isset( $_GET['action'] ) && in_array( $_GET['action'], array( 'new', 'edit' ) ) ) {
173 wp_enqueue_script( 'post' );
174 wp_enqueue_media();
175
176 $country = \WeDevs\ERP\Countries::instance();
177 wp_localize_script( 'erp-script', 'wpErpCountries', $country->load_country_states() );
178 }
179
180 if ( 'hr-management_page_erp-hr-employee' == $hook ) {
181 $country = \WeDevs\ERP\Countries::instance();
182 wp_localize_script( 'erp-script', 'wpErpCountries', $country->load_country_states() );
183 }
184 }
185
186 /**
187 * Enqueue the stylesheet
188 *
189 * @return void
190 */
191 public function enqueue_styles() {
192 wp_enqueue_style( 'erp-fontawesome' );
193 wp_enqueue_style( 'erp-select2' );
194 wp_enqueue_style( 'jquery-ui' );
195
196 wp_enqueue_style( 'erp-styles' );
197 }
198 }
199